<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <script th:src="@{/static/js/vue3.4.21.js}"></script>
    <script th:src="@{/static/js/axios.min.js}"></script>
</head>
<body>
<h1>首页</h1>
<hr>

<div id="app">
    <h1>{{message}}</h1>
    <button @click="getMessage">获取消息</button>
</div>
<form th:action="@{/request}" method="post">
    name: <input type="text" name="name" value="name">
    password: <input type="password" name="password" value="password">
    <input type="submit" value="submit">
</form>

<script th:inline="javascript">
    Vue.createApp({
        data(){
            return {
                message : "这里的信息将被刷新"
            }
        },
        methods:{
            async getMessage(){
                try {
                    const response = await axios.get([[@{/}]] + 'hello')
                        this.message = response.data
                } catch (e) {
                        console.error(e)
                    }
                }
            }
        }).mount("#app")
</script>

</body>
</html>